import imageList from "./list.json";
/* 取值随机数区间 */
function getRandomNumberByRange(start, end) {
    return Math.floor(Math.random() * (end - start) + start)
}
/* 保证数据稳定性,避免每次刷新数据都不一样,则数据只生成一次,关闭页签再打开会刷新一次 */
let shopList = JSON.parse(sessionStorage.getItem("shopList")) || [];
if (shopList.length === 0) {
    imageList.forEach(item => {
        let shopItem = {
            image: item.image,// 图片路径
            title: item.title,
            selectType: getRandomNumberByRange(1, 10),// 分类
            synthesize: getRandomNumberByRange(0, imageList.length),// 综合排序
            salesVolume: getRandomNumberByRange(10, 10000),// 销量
            pic: getRandomNumberByRange(12, 98),// 价格
        }
        shopList.push(shopItem);
    })
}
sessionStorage.setItem("shopList", JSON.stringify(shopList))
export default shopList;